@model OrderDetailsModel
@using Nop.Web.Models.Order
@{
   if (!Model.PrintMode)
   {
       Layout = "~/Views/Shared/_ColumnsOne.cshtml";
   }
   else
   {
       Layout = "~/Views/Shared/_Print.cshtml";
   }
   //title
   Html.AddTitleParts(T("PageTitle.OrderDetails").Text);
}
@if (Model.PrintMode)
{
   <script type="text/javascript">
       $(document).ready(function () {
           window.print();
       });
   </script>
}
<div class="page order-details-page">
   @if (!Model.PrintMode)
   {
       <div class="page-title">
           <h1>@T("Order.OrderInformation")</h1>
           <a href="@Url.RouteUrl("PrintOrderDetails", new { orderId = Model.Id })" target="_blank" class="button-2 print-order-button">@T("Order.Print")</a>
           @if (!Model.PdfInvoiceDisabled)
           {
               <a href="@Url.RouteUrl("GetOrderPdfInvoice", new { orderId = Model.Id })" class="button-2 pdf-invoice-button">@T("Order.GetPDFInvoice")</a>
           }
       </div>
   }
   <div class="page-body">
       @Html.Widget("orderdetails_page_top", Model.Id)

       <div class="order-overview">
           <div class="order-number">
               <strong>@T("Order.Order#")@Model.Id</strong>
           </div>
           <div class="order-date">
               @T("Order.OrderDate"): @Model.CreatedOn.ToString("D")
           </div>
           <div class="order-status">
               @T("Order.OrderStatus"): @Model.OrderStatus
           </div>
           <div class="order-total">
               @T("Order.OrderTotal"): <strong>@Model.OrderTotal</strong>
           </div>
           @Html.Widget("orderdetails_page_overview", Model.Id)
       </div>

       <div class="order-details-area">
           <ul class="billing-info">
               <li class="title">
                   @T("Order.BillingAddress")
               </li>
               <li class="name">
                   @Model.BillingAddress.FirstName @Model.BillingAddress.LastName
               </li>
               <li class="email">
                   @T("Order.Email"): @Model.BillingAddress.Email
               </li>
               @if (Model.BillingAddress.PhoneEnabled)
               {
                   <li class="phone">
                       @T("Order.Phone"): @Model.BillingAddress.PhoneNumber
                   </li>
               }
               @if (Model.BillingAddress.FaxEnabled)
               {
                   <li class="fax">
                       @T("Order.Fax"): @Model.BillingAddress.FaxNumber
                   </li>
               }
               @if (Model.BillingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.BillingAddress.Company))
               {
                   <li class="company">
                       @Model.BillingAddress.Company
                   </li>
               }
               @if (Model.BillingAddress.StreetAddressEnabled)
               {
                   <li class="address1">
                       @Model.BillingAddress.Address1
                   </li>
               }
               @if (Model.BillingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.BillingAddress.Address2))
               {
                   <li class="address2">
                       @Model.BillingAddress.Address2
                   </li>
               }
               @if (Model.BillingAddress.CityEnabled ||
           Model.BillingAddress.StateProvinceEnabled ||
           Model.BillingAddress.ZipPostalCodeEnabled)
               {
                   <li class="city-state-zip">
                       @if (Model.BillingAddress.CityEnabled)
                       {
                           @Model.BillingAddress.City
                       }
                       @if (Model.BillingAddress.CityEnabled && (Model.BillingAddress.StateProvinceEnabled || Model.BillingAddress.ZipPostalCodeEnabled))
                       {
                           <text>,</text>
                       }
                       @if (Model.BillingAddress.StateProvinceEnabled)
                       {
                           @Model.BillingAddress.StateProvinceName
                       }
                       @if (Model.BillingAddress.ZipPostalCodeEnabled)
                       {
                           @Model.BillingAddress.ZipPostalCode
                       }
                   </li>
               }
               @if (Model.BillingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.BillingAddress.CountryName))
               {
                   <li class="country">
                       @Model.BillingAddress.CountryName
                   </li>
               }
               @if (!String.IsNullOrEmpty(Model.VatNumber))
               {
                   <li class="vat">
                       <span class="label">
                           @T("Order.VATNumber")
                       </span>
                       <span class="value">
                           @Model.VatNumber
                       </span>
                   </li>
               }
               @if (!String.IsNullOrEmpty(Model.BillingAddress.FormattedCustomAddressAttributes))
               {
                   <li class="custom-attributes-view">
                       @Html.Raw(Model.BillingAddress.FormattedCustomAddressAttributes)
                   </li>
               }
               @if (!String.IsNullOrEmpty(Model.PaymentMethod))
               {
                   <li class="title">
                       @T("Order.Payment")
                   </li>
                   <li class="payment-method">
                       <span class="label">
                           @T("Order.Payment.Method"):
                       </span>
                       <span class="value">
                           @Model.PaymentMethod
                       </span>
                   </li>
                   if (!Model.PrintMode)
                   {
                       <li class="payment-method-status">
                           <span class="label">
                               @T("Order.Payment.Status"):
                           </span>
                           <span class="value">
                               @Model.PaymentMethodStatus
                           </span>
                       </li>
                   }
                   if (!Model.PrintMode && Model.CanRePostProcessPayment)
                   {
                       @*Complete payment (for redirection payment methods)*@
                   <li class="repost">
                       @using (Html.BeginRouteForm("OrderDetails", FormMethod.Post))
                       {
                           @Html.AntiForgeryToken()
                           <input type="submit" name="repost-payment" value="@T("Order.RetryPayment")" class="button-2 re-order-button" />
                           <p class="hint">
                               <em>@T("Order.RetryPayment.Hint")</em>
                           </p>
                       }
                   </li>
                   }
               }
               @if (Model.CustomValues != null)
               {
                   foreach (var item in Model.CustomValues)
                   {
                       <li class="custom-value">
                           <span class="label">
                               @item.Key:
                           </span>
                           <span class="value">
                               @(item.Value != null ? item.Value.ToString() : "")
                           </span>
                       </li>
                   }
               }
           </ul>
           @if (Model.IsShippable)
           {
               <ul class="shipping-info">
                   @if (!Model.PickUpInStore)
                   {

                       <li class="title">
                           @T("Order.ShippingAddress")
                       </li>
                       <li class="name">
                           @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName
                       </li>
                       <li class="email">
                           @T("Order.Email"): @Model.ShippingAddress.Email
                       </li>
                       if (Model.ShippingAddress.PhoneEnabled)
                       {
                           <li class="phone">
                               @T("Order.Phone"): @Model.ShippingAddress.PhoneNumber
                           </li>
                       }
                       if (Model.ShippingAddress.FaxEnabled)
                       {
                           <li class="fax">
                               @T("Order.Fax"): @Model.ShippingAddress.FaxNumber
                           </li>
                       }
                       if (Model.ShippingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.Company))
                       {
                           <li class="company">
                               @Model.ShippingAddress.Company
                           </li>
                       }
                       if (Model.ShippingAddress.StreetAddressEnabled)
                       {
                           <li class="address1">
                               @Model.ShippingAddress.Address1
                           </li>
                       }
                       if (Model.ShippingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.ShippingAddress.Address2))
                       {
                           <li class="address2">
                               @Model.ShippingAddress.Address2
                           </li>
                       }
                       if (Model.ShippingAddress.CityEnabled ||
                           Model.ShippingAddress.StateProvinceEnabled ||
                           Model.ShippingAddress.ZipPostalCodeEnabled)
                       {
                           <li class="city-state-zip">
                               @if (Model.ShippingAddress.CityEnabled)
                               {
                                   @Model.ShippingAddress.City
                               }
                               @if (Model.ShippingAddress.CityEnabled && (Model.ShippingAddress.StateProvinceEnabled || Model.ShippingAddress.ZipPostalCodeEnabled))
                               {
                                   <text>,</text>
                               }
                               @if (Model.ShippingAddress.StateProvinceEnabled)
                               {
                                   @Model.ShippingAddress.StateProvinceName
                               }
                               @if (Model.ShippingAddress.ZipPostalCodeEnabled)
                               {
                                   @Model.ShippingAddress.ZipPostalCode
                               }
                           </li>
                       }
                       if (Model.ShippingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.CountryName))
                       {
                           <li class="country">
                               @Model.ShippingAddress.CountryName
                           </li>
                       }
                       if (!String.IsNullOrEmpty(Model.ShippingAddress.FormattedCustomAddressAttributes))
                       {
                           <li class="custom-attributes-view">
                               @Html.Raw(Model.ShippingAddress.FormattedCustomAddressAttributes)
                           </li>
                       }
                   }
                   <li class="title">
                       @T("Order.Shipping")
                   </li>
                   <li class="shipping-method">
                       <span class="label">
                           @T("Order.Shipping.Name"):
                       </span>
                       <span class="value">
                           @Model.ShippingMethod
                       </span>
                   </li>
                   @if (!Model.PrintMode && !Model.PickUpInStore)
                   {
                       <li class="shipping-status">
                           <span class="label">
                               @T("Order.Shipping.Status"):
                           </span>
                           <span class="value">
                               @Model.ShippingStatus
                           </span>
                       </li>
                   }
               </ul>
           }
       </div>

       @if (Model.Items.Count > 0)
       {
           @Html.Widget("orderdetails_page_beforeproducts", Model.Id)
           <div class="section products">
               <div class="title">
                   <strong>@T("Order.Product(s)")</strong>
               </div>
               <div class="table-wrapper">
                   <table class="data-table">
                       <colgroup>
                           @if (Model.ShowSku)
                           {
                               <col width="1" />
                           }
                           <col />
                           <col width="1" />
                           <col width="1" />
                           <col width="1" />
                       </colgroup>
                       <thead>
                           <tr>
                               @if (Model.ShowSku)
                               {
                                   <th class="sku">
                                       @T("Order.Product(s).SKU")
                                   </th>
                               }
                               <th class="name">
                                   @T("Order.Product(s).Name")
                               </th>
                               <th class="price">
                                   @T("Order.Product(s).Price")
                               </th>
                               <th class="quantity">
                                   @T("Order.Product(s).Quantity")
                               </th>
                               <th class="total">
                                   @T("Order.Product(s).Total")
                               </th>
                           </tr>
                       </thead>
                       <tbody>
                           @foreach (var item in Model.Items)
                           {
                               <tr>
                                   @if (Model.ShowSku)
                                   {
                                       <td class="sku">
                                            <label class="td-title">@T("Order.Product(s).SKU"):</label>
                                            <span class="sku-number">@item.Sku</span>
                                       </td>
                                   }
                                   <td class="product">
                                       @if (!Model.PrintMode)
                                       {
                                           <em><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a></em>
                                       }
                                       else
                                       {
                                           @item.ProductName
                                       }
                                       @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                       {
                                           <div class="attributes">
                                               @Html.Raw(item.AttributeInfo)
                                           </div>
                                       }
                                       @if (!String.IsNullOrEmpty(item.RentalInfo))
                                       {
                                           <div class="rental-info">
                                               @Html.Raw(item.RentalInfo)
                                           </div>
                                       }
                                       @if (item.DownloadId > 0)
                                       {
                                           <div class="download">
                                               <a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">@T("DownloadableProducts.Fields.Download")</a>
                                           </div>
                                       }
                                       @if (item.LicenseId > 0)
                                       {
                                           <div class="download license">
                                               <a href="@Url.RouteUrl("GetLicense", new {orderItemId = item.OrderItemGuid})">@T("DownloadableProducts.Fields.DownloadLicense")</a>
                                           </div>
                                       }
                                       @Html.Widget("orderdetails_product_line", item.Id)
                                   </td>
                                   <td class="unit-price">
                                        <label class="td-title">@T("Order.Product(s).Price"):</label>
                                        <span class="product-unit-price">@item.UnitPrice</span>
                                   </td>
                                   <td class="quantity">
                                        <label class="td-title">@T("Order.Product(s).Quantity"):</label>
                                        <span class="product-quantity">@item.Quantity</span>
                                   </td>
                                   <td class="total">
                                        <label class="td-title">@T("Order.Product(s).Total"):</label>
                                        <span class="product-subtotal">@item.SubTotal</span>
                                   </td>
                               </tr>
                           }
                       </tbody>
                   </table>
               </div>
           </div>
           @Html.Widget("orderdetails_page_afterproducts", Model.Id)

           <div class="section options">
               @if (Model.Items.Count > 0 && Model.DisplayTaxShippingInfo)
               {
                   var inclTax = Model.PricesIncludeTax;
                   //tax info is already included in the price (incl/excl tax). that's why we display only shipping info here
                   //of course, you can modify appropriate locales to include VAT info there
                   <div class="tax-shipping-info">
                       @T(inclTax ? "Order.TaxShipping.InclTax" : "Order.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = Html.GetTopicSeName("shippinginfo") }))
                   </div>
               }
               @if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
               {
                   <div class="selected-checkout-attributes">
                       @Html.Raw(Model.CheckoutAttributeInfo)
                   </div>
               }
               @if (!Model.PrintMode)
               {
                   <div class="actions">
                       @if (Model.IsReOrderAllowed)
                       {
                           <input type="button" value="@T("Order.Reorder")" class="button-1 re-order-button" onclick="setLocation('@Url.RouteUrl("ReOrder", new { orderId = Model.Id })    ')" />
                       }
                       @if (Model.IsReturnRequestAllowed)
                       {
                           <input type="button" value="@T("Order.ReturnItems")" class="button-2 return-items-button" onclick="setLocation('@Url.RouteUrl("ReturnRequest", new { orderId = Model.Id })    ')" />
                       }
                   </div>
               }
           </div>
           
           <div class="section totals">
               <div class="total-info">
                   <table class="cart-total">
                       <tbody>
                           <tr>
                               <td class="cart-total-left">
                                   <label>@T("Order.SubTotal"):</label>
                               </td>
                               <td class="cart-total-right">
                                   <span>@Model.OrderSubtotal</span>
                               </td>
                           </tr>
                           @if (!string.IsNullOrEmpty(Model.OrderSubTotalDiscount))
                           {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@T("Order.SubTotalDiscount"):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@Model.OrderSubTotalDiscount</span>
                                   </td>
                               </tr>
                           }
                           @if (Model.IsShippable)
                           {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@T("Order.Shipping"):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@Model.OrderShipping</span>
                                   </td>
                               </tr>
                           }
                           @if (!string.IsNullOrEmpty(Model.PaymentMethodAdditionalFee))
                           {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@T("Order.PaymentMethodAdditionalFee"):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@Model.PaymentMethodAdditionalFee</span>
                                   </td>
                               </tr>
                           }
                           @if (Model.DisplayTaxRates && Model.TaxRates.Count > 0)
                           {
                               foreach (var taxRate in Model.TaxRates)
                               {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@string.Format(T("Order.TaxRateLine").Text, taxRate.Rate):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@taxRate.Value</span>
                                   </td>
                               </tr>
                               }
                           }
                           @if (Model.DisplayTax)
                           {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@T("Order.Tax"):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@Model.Tax</span>
                                   </td>
                               </tr>
                           }
                           @if (!string.IsNullOrEmpty(Model.OrderTotalDiscount))
                           {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@T("Order.TotalDiscount"):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@Model.OrderTotalDiscount</span>
                                   </td>
                               </tr>
                           }
                           @if (Model.GiftCards.Count > 0)
                           {
                               foreach (var gc in Model.GiftCards)
                               {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@string.Format(T("Order.GiftCardInfo").Text, gc.CouponCode):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@gc.Amount</span>
                                   </td>
                               </tr>
                               }
                           }
                           @if (Model.RedeemedRewardPoints > 0)
                           {
                               <tr>
                                   <td class="cart-total-left">
                                       <label>@string.Format(T("Order.RewardPoints").Text, Model.RedeemedRewardPoints):</label>
                                   </td>
                                   <td class="cart-total-right">
                                       <span>@Model.RedeemedRewardPointsAmount</span>
                                   </td>
                               </tr>
                           }
                           <tr>
                               <td class="cart-total-left">
                                   <label>@T("Order.OrderTotal"):</label>
                               </td>
                               <td class="cart-total-right">
                                   <span><strong>@Model.OrderTotal</strong></span>
                               </td>
                           </tr>
                       </tbody>
                   </table>
               </div>
           </div>
       }
       @if (!Model.PrintMode)
       {
           if (Model.Shipments.Count > 0)
           {
           <div class="section shipments">
               <div class="title">
                   <strong>@T("Order.Shipments")</strong>
               </div>
               <div class="table-wrapper">
                   <table class="data-table">
                       <colgroup>
                           <col width="1" />
                           <col />
                           <col />
                           <col />
                           <col />
                       </colgroup>
                       <thead>
                           <tr>
                               <th class="shipment-id">
                                   @T("Order.Shipments.ID")
                               </th>
                               <th class="tracking-number">
                                   @T("Order.Shipments.TrackingNumber")
                               </th>
                               <th class="shipping-date">
                                   @T("Order.Shipments.ShippedDate")
                               </th>
                               <th class="delivery-date">
                                   @T("Order.Shipments.DeliveryDate")
                               </th>
                               <th class="view-details">
                                   @T("Order.Shipments.ViewDetails")
                               </th>
                           </tr>
                       </thead>
                       <tbody>
                           @foreach (var item in Model.Shipments)
                           {
                               <tr>
                                   <td class="shipment-id">
                                        <label>@T("Order.Shipments.ID"):</label>
                                        <span>@item.Id.ToString()</span>
                                   </td>
                                   <td class="tracking-number">
                                        <label>@T("Order.Shipments.TrackingNumber"):</label>
                                       @item.TrackingNumber
                                   </td>
                                   <td class="shipped-date">
                                        <label>@T("Order.Shipments.ShippedDate"):</label>
                                       @if (item.ShippedDate.HasValue)
                                       {
                                            <span>@item.ShippedDate.Value.ToString("D")</span>
                                       }
                                       else
                                       {
                                            <span>@T("Order.Shipments.ShippedDate.NotYet")</span>
                                       }
                                   </td>
                                   <td class="delivery-date">
                                        <label>@T("Order.Shipments.DeliveryDate"):</label>
                                       @if (item.DeliveryDate.HasValue)
                                       {
                                            <span>@item.DeliveryDate.Value.ToString("D")</span>
                                       }
                                       else
                                       {
                                            <span>@T("Order.Shipments.DeliveryDate.NotYet")</span>
                                       }
                                   </td>
                                   <td class="view-details">
                                       <a href="@Url.RouteUrl("ShipmentDetails", new { shipmentId = item.Id })" title="@T("Order.Shipments.ViewDetails")">@T("Order.Shipments.ViewDetails")</a>
                                   </td>
                               </tr>
                           }
                       </tbody>
                   </table>
               </div>
           </div>
           }
       }
       @if (!Model.PrintMode)
       {
           if (Model.OrderNotes.Count > 0)
           {
           <div class="section order-notes">
               <div class="title">
                   <strong>@T("Order.Notes")</strong>
               </div>
               <div class="table-wrapper">
                   <table class="data-table">
                       <colgroup>
                           <col />
                           <col />
                       </colgroup>
                       <thead>
                           <tr>
                               <th class="created-on">
                                   @T("Order.Notes.CreatedOn")
                               </th>
                               <th class="note">
                                   @T("Order.Notes.Note")
                               </th>
                           </tr>
                       </thead>
                       <tbody>
                           @foreach (var item in Model.OrderNotes)
                           {
                               <tr>
                                   <td class="created-on">
                                       @item.CreatedOn.ToString()
                                   </td>
                                   <td class="note">
                                       @Html.Raw(item.Note)
                                       @if (item.HasDownload)
                                       {
                                           <p class="download">
                                               <a href="@Url.RouteUrl("GetOrderNoteFile", new { ordernoteid = item.Id })">@T("Order.Notes.Download")</a>
                                           </p>
                                       }
                                   </td>
                               </tr>
                           }
                       </tbody>
                   </table>
               </div>
           </div>
           }
       }
       @Html.Widget("orderdetails_page_bottom", Model.Id)
   </div>
</div>